package com.y4oung.service.impl;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import com.huaban.analysis.jieba.JiebaSegmenter;
import com.y4oung.model.Business;
import org.springframework.stereotype.Service;

import com.y4oung.dao.ISearchDao;
import com.y4oung.model.SearchHistory;
import com.y4oung.service.ISearchService;

@Service("searchService")
public class SearchServiceImpl implements ISearchService{
	
	@Resource
	private ISearchDao SearchDao;
	SearchHistory sh = new SearchHistory();
	
	public List<SearchHistory> showSearch(int userId){
		return SearchDao.showSearch(userId);
	}
	
	public void insertSearch(int userId,Date time,String keyword){
		sh.setUser_id(userId);
		sh.setTime(time);
		sh.setKeyword(keyword);
		SearchDao.insertSearch(sh);
	}
	
	public void deleteSearch(int userId){
		SearchDao.deleteSearch(userId);
	}

	public List<Business> mainSearch(String content){
		JiebaSegmenter segmenter = new JiebaSegmenter();
		Object[] keyword = segmenter.process(content,JiebaSegmenter.SegMode.SEARCH).toArray();
		List<Business> blist = new ArrayList<Business>();
		//blist = SearchDao.showSearch(keyword);
		return blist;
	}
}
